/*
 * Copyright (C) 2015 The Android  Source Project 
 *
 * Licensed under the Apache License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 *
 *      http://www.ido517.com
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */
package com.ygk.bluepath.core;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.umeng.analytics.MobclickAgent;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.ImageView;
import android.widget.Toast;
import utils.LogUtils;
import utils.SharedPreUtil;

/**
 * @Description TODO
 * @author 李文伟
 * @email lvsedewenzi@163.com
 * @date 2015-11-17 下午1:00:31
 */
public class BFragment extends Fragment {
	public BApp app = BApp.getInstance();
	public SharedPreUtil sp = app.getSharedPreUtil();
	protected String Photos_cache = app.getmPicCache();
	protected ImageLoader mImageLoader = app.getmImageLoader();

	public void tt(final String string) {
		// TODO Auto-generated method stub

		if (string != null && !string.equals("")) {
			getActivity().runOnUiThread(new Runnable() {

				@Override
				public void run() {
					// TODO Auto-generated method stub
					Toast.makeText(app, string, Toast.LENGTH_SHORT).show();
				}
			});
		}

	}

	@Override
	public void onResume() {
		super.onResume();
		MobclickAgent.onPageStart(getViewID()); // 统计页面，"getViewID()"为页面名称，可自定义
	}

	@Override
	public void onPause() {
		super.onPause();
		MobclickAgent.onPageEnd(getViewID());//统计页面
	}
	/**
	 * @Description: TODO
	 * @param
	 * @return void
	 * @throws
	 */
	protected void disPlayImage(String Url, ImageView iv) {
		// TODO Auto-generated method stub
		mImageLoader.displayImage(Url, iv);
	}

	/**
	 * @Description: TODO
	 * @param
	 * @return void
	 * @throws
	 */
	protected void disPlayImage(String Url, ImageView iv,
								DisplayImageOptions dio) {
		// TODO Auto-generated method stub
		mImageLoader.displayImage(Url, iv, dio);
	}

	public String getPhotos_cache() {
		return Photos_cache;
	}

	protected String viewID = "";

	/**
	 * @Description: TODO
	 * @param @return
	 * @return String
	 * @throws
	 */
	private String getViewID() {
		// TODO Auto-generated method stub

		if (viewID.equals("")) {
			String contextString = this.toString();
			viewID = contextString.substring(0, contextString.indexOf("{"));
		}
		LogUtils.e("getViewID----" + viewID);
		return viewID;
	}

	protected void sta(Context packageContext, Class<?> cls) {
		startActivity(new Intent().setClass(packageContext, cls));
	}

	protected void staWBundle(Context packageContext, Class<?> cls, Bundle bd) {
		startActivity(new Intent().setClass(packageContext, cls).putExtras(bd));
	}

}
